package com.example.demo.service.Impl;


import com.example.demo.dao.IUcmana;
import com.example.demo.model.Ucmana;
import com.example.demo.service.IUcmanaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Administrator 张少婷
 */

@Service
public class UcmanaServiceImpl implements IUcmanaService {

    @Autowired
    private IUcmana ucmanaMapper;
    @Override
    public int insertUcmana(Ucmana ucmana){
        int ucmanaValue=0;

       Ucmana ucmana1=new Ucmana();
        ucmana1.setYgid(ucmana.getYgid());
        List<Ucmana> getC=ucmanaMapper.getAllUcmana(ucmana1);
        if(getC.size()>0){
            ucmanaValue=-1;

        }else{
            ucmanaValue=ucmanaMapper.insertUcmana(ucmana);
        }

        return ucmanaValue;
    }

    @Override
    public List<Ucmana> getAllUcmana(Ucmana ucmana) {


        return ucmanaMapper.getAllUcmana(ucmana);
    }

    @Override
    public int updateUcmana(Ucmana ucmana) {
        int ucmanaValues=0;
        if(ucmana.getYgid()!=0){

            ucmanaValues=ucmanaMapper.updateUcmana(ucmana);
        }
        return ucmanaValues;
    }

    @Override
    public int deleteUcmana(Ucmana ucmana) {
        int ucmanaValues=0;
        if(ucmana.getYgid()!=0){
            //主键是否与其他表有关联

           ucmanaValues=ucmanaMapper.deleteUcmana(ucmana);
        }
        return ucmanaValues;
    }

    @Override
    public Ucmana getUcmana(Ucmana ucmana) {
        Ucmana ucmana1=new Ucmana();
        if(ucmana.getYgid()!=0){
            ucmana1=ucmanaMapper.getUcmana(ucmana);
        }
        return ucmana1;
    }

}
